<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        .countdown {
            /* 写个牛逼的动画，实现倒计时效果 */
            animation: countdown 5s infinite;
            display: flex;
            justify-content: center;
            align-items: center;
        }
    </style>
</head>

<body>
    <div class="countdown">
    </div>
    <script>
        // 请补全代码，并实现倒计时逻辑
        let totalSeconds = 24 // 你可以修改为任意初始秒数
        const time = { day: 0, hour: 0, min: 0, second: 0 }
        let timer = null;

        function second(s) {
            time.day = Math.floor(s / (24 * 60 * 60));
            const t1 = Math.floor(s % (24 * 60 * 60));
            time.hour = Math.floor(t1 / (60 * 60));
            const t2 = Math.floor(t1 % (60 * 60));
            time.min = Math.floor(t2 / 60);
            time.second = Math.floor(t2 % 60);
            format();
        }
        function format() {
            for (let k in time) {
                time[k] = time[k] >= 10 ? time[k] : '0' + time[k];
            }
            document.querySelector('.countdown').innerHTML = `${time.day}天 ${time.hour}时 ${time.min}分 ${time.second}秒`;
        }

        function tick() {
            timer = setInterval(() => {
                totalSeconds--;
                if (totalSeconds <= 0) {
                    clearInterval(timer);
                    timer = null;
                }
                second(totalSeconds);
            }, 1000)
        }
        tick();

        Array.prototype.myMap = function (callback) {
            const arr = [];
            for (let i = 0; i < this.length; i++) {
                arr.push(callback(this[i], i, this));
            }
            return arr;
        }
        const arr = [1, 2, 3, 4, 5];
        console.log(arr.myMap(item => item * 2)); // [2, 4, 6, 8, 10]
    </script>
</body>

</html>